﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MyAlarm
{
    

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            Timer timer = new Timer();
            timer.Enabled = true;
            timer.Interval = 1000;
            timer.Tick += new System.EventHandler(this.newTick);
            timer.Tick += new System.EventHandler(this.newAlarm);
        }

        private void newAlarm(object sender, EventArgs e)
        {
            try
            {
                int nowSecond = System.DateTime.Now.Second;
                if (nowSecond % 20 == 0)
                {
                    myTextBox.Text += "\r\n\r\nAlarm!!!!!!!!!!!!!!!!\r\n\r\n";
                }
            }
            catch (Exception a)
            {
                MessageBox.Show(a.Message);
            }

        }

        private void newTick(object sender, EventArgs e)
        {
            try
            {
                string nowTime = System.DateTime.Now.ToString();
                myTextBox.Text += "Tick," + "now is " + nowTime + "\r\n";
            }
            catch (Exception a)
            {
                MessageBox.Show(a.Message);
            }
        }

        
    }
}
